import { Button, Modal } from '@/components'
import { InboxOutlined } from '@ant-design/icons'
import type { UploadProps } from 'antd'
import { Upload, message } from 'antd'
import { useState } from 'react'

const { Dragger } = Upload

const props: UploadProps = {
  name: 'file',
  maxCount: 1,
  action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
  onChange(info) {
    const { status } = info.file
    if (status !== 'uploading') {
      console.log(info.file, info.fileList)
    }
    if (status === 'done') {
      message.success(`${info.file.name} file uploaded successfully.`)
    } else if (status === 'error') {
      message.error(`${info.file.name} file upload failed.`)
    }
  },
  onDrop(e) {
    console.log('Dropped files', e.dataTransfer.files)
  }
}

export const CheckModal = () => {
  const [open, setOpen] = useState(false)
  const [checkable, setCheckable] = useState(false)
  return (
    <Modal title="规则校验" open={open} centered footer={<Button type="primary">校验</Button>}>
      <Dragger {...props}>
        <p className="ant-upload-drag-icon">
          <InboxOutlined />
        </p>
        <p className="ant-upload-text">请上传校验文件（Pcap包）</p>
      </Dragger>
    </Modal>
  )
}
